<template>
	<div class="model">
		<h2 class="model__title">
			订单详情<span v-if="data" style="color: #f60;">({{data.order_state.order_state_name}})</span>
			<span @click="close" class="model__title--close">&times;</span>
		</h2>
		<div class="model__content" v-loading="loading">
			<div v-if="data">
				<div class="item">
					<div class="item__title">下单/支付</div>
					<div>
						<div class="item__detail">
							<span class="item__detail--title">订单流水号:</span>
							<span class="item__detail--value">{{data.flow_no}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">是否开票:</span>
							<el-tag type="success" v-if="data.need_invoice" size="small">开票</el-tag>
							<el-tag type="warning" v-else size="small">不开票</el-tag>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">支付流水号:</span>
							<span class="item__detail--value">{{data.pay_flow_no}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">下单时间:</span>
							<span v-if="data.create_time">{{data.create_time | formatTime}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">支付金额:</span>
							<span class="item__detail--value">{{data.pay_money}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">支付账号:</span>
							<span class="item__detail--value">{{data.pay_account}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">收到金额:</span>
							<span class="item__detail--value">{{data.receipt_money}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">支付时间:</span>
							<span v-if="data.pay_time">{{data.pay_time | formatTime}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">支付时间确认:</span>
							<span v-if="data.pay_confirm_time">{{data.pay_confirm_time | formatTime}}</span>
						</div>
					</div>
				</div>

				<div class="item" v-if="data.member">
					<div class="item__title">买家信息</div>
					<div v-if="data.member">
						<div class="item__detail">
							<span class="item__detail--title">真实姓名:</span>
							<span class="item__detail--value">{{data.member.real_name}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">昵称:</span>
							<span class="item__detail--value">{{data.member.nick_name}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">手机号:</span>
							<span class="item__detail--value">{{data.member.mobile}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">性别</span>
							<span v-if="data.member.sex">男</span>
							<span v-else>女</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">邮箱:</span>
							<span class="item__detail--value">{{data.member.email}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">成长值:</span>
							<span class="item__detail--value">{{data.member.grow_value}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">线上现金成长值:</span>
							<span class="item__detail--value">{{data.member.on_cash_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">线下现金成长值:</span>
							<span class="item__detail--value">{{data.member.off_cash_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">线上点元成长值:</span>
							<span class="item__detail--value">{{data.member.on_yuan_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">线下点元成长值:</span>
							<span class="item__detail--value">{{data.member.off_yuan_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">线上点分成长值:</span>
							<span class="item__detail--value">{{data.member.on_fen_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">消费频率成长值:</span>
							<span class="item__detail--value">{{data.member.rf_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">消费激励成长值:</span>
							<span class="item__detail--value">{{data.member.cost_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">活跃成长值:</span>
							<span class="item__detail--value">{{data.member.login_grow}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">连续签到天数:</span>
							<span class="item__detail--value">{{data.member.continue_signin_days}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">用户身份:</span>
							<span class="item__detail--value">
							<el-tag v-if="data.member.is_saleman" size="small">推广大使</el-tag>
							<el-tag v-if="data.member.is_manager" size="small">区域经理</el-tag>
							<el-tag v-if="data.member.is_company_manager" size="small">推广商家</el-tag>
							<el-tag 
								size="small"
								type="info"
								v-if="!data.member.is_saleman&&!data.member.is_manager&&!data.member.is_company_manager"
								>普通用户
							</el-tag>	
						</span>
						</div>
					</div>
				</div>

				<div class="item">
					<div class="item__title">地址信息</div>
					<div v-if="data.address">
						<div class="item__detail">
							<span class="item__detail--title">收货地址:</span>
							<span class="item__detail--value">{{data.address.address}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">收货人:</span>
							<span class="item__detail--value">{{data.address.person}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">移动电话:</span>
							<span class="item__detail--value">{{data.address.mobile}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">固定电话:</span>
							<span class="item__detail--value">{{data.address.tel}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">邮政编号:</span>
							<span class="item__detail--value">{{data.address.zipcode}}</span>
						</div>
					</div>
				</div>

				<div class="item">
					<div class="item__title">商家信息</div>
					<div v-if="data.company">
						<div class="item__detail">
							<span class="item__detail--title">商家名:</span>
							<span class="item__detail--value">{{data.company.company_name}}</span>
						</div>
					</div>
				</div>

				<div class="item">
					<div class="item__title">仓库信息</div>
					<div v-if="data.warehouse">
						<div class="item__detail">
							<span class="item__detail--title">仓库名:</span>
							<span class="item__detail--value">{{data.warehouse.warehouse_name}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">仓库地址:</span>
							<span class="item__detail--value">{{data.warehouse.address}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">联系人:</span>
							<span class="item__detail--value">{{data.warehouse.linkman}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">移动电话:</span>
							<span class="item__detail--value">{{data.warehouse.mobile}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">固定电话:</span>
							<span class="item__detail--value">{{data.warehouse.tel}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">传真:</span>
							<span class="item__detail--value">{{data.warehouse.fax_no}}</span>
						</div>
					</div>
				</div>

				<div class="item">
					<div class="item__title">价格信息</div>
					<div>
						<div class="item__detail">
							<span class="item__detail--title">点币金额:</span>
							<span class="item__detail--value">{{data.bi_money}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">订单金额:</span>
							<span class="item__detail--value">{{data.order_money}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">支付金额:</span>
							<span class="item__detail--value">{{data.pay_money}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">运费:</span>
							<span class="item__detail--value">{{data.post_fee}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">点元:</span>
							<span class="item__detail--value">{{data.dian_yuan}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">点币:</span>
							<span class="item__detail--value">{{data.dian_bi}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">点分:</span>
							<span class="item__detail--value">{{data.dian_fen}}</span>
						</div>
					</div>
				</div>

				<div class="item">
					<div class="item__title">发票信息</div>
					<div v-if="data.invoice">
						<div class="item__detail">
							<span class="item__detail--title">发票抬头:</span>
							<span class="item__detail--value">{{data.invoice.invoice_title}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">发票内容:</span>
							<span class="item__detail--value">{{data.invoice.content}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">发票金额:</span>
							<span class="item__detail--value">{{data.invoice.invoice_money}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">发票类型:</span>
							<span class="item__detail--value">{{data.invoice.invoice_type}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">税号:</span>
							<span class="item__detail--value">{{data.invoice.tax_no}}</span>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">开票时间:</span>
							<span class="item__detail--value">{{data.invoice.invoice_time}}</span>
						</div>
					</div>
				</div>

				<div class="item">
					<div class="item__title">订单属性</div>
					<div>
						<div class="item__detail">
							<span class="item__detail--title">是否开票:</span>
							<el-tag v-if="data.need_invoice" type="success" size="mini">开票</el-tag>
							<el-tag v-else type="warning" size="mini">不开票</el-tag>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">可否退货:</span>
							<el-tag v-if="data.may_return" type="success" size="mini">可以</el-tag>
							<el-tag v-else type="danger" size="mini">不可以</el-tag>
						</div>
						<div class="item__detail">
							<span class="item__detail--title">可否换货:</span>
							<el-tag v-if="data.may_exchange" type="success" size="mini">可以</el-tag>
							<el-tag v-else type="danger" size="mini">不可以</el-tag>
						</div>
					</div>
				</div>

				<div class="item">
					<div class="item__title">商品详情</div>
					<div class="goods">
						<el-table :data="data.commodities" strip>
							<el-table-column label="商品编号" align="center">
								<template slot-scope="scope">
									<span class="item__detail--value">{{scope.row.commodity_no}}</span>
								</template>
							</el-table-column>
							<el-table-column label="商品名称" align="center" width="350">
								<template slot-scope="scope">
									<div class="img-desc">
										<img :src="scope.row.mainimg.url" v-if="scope.row.mainimg" class="img-desc__img"/>
										<span>{{scope.row.commodity_name}}</span>
									</div>
								</template>
							</el-table-column>
							<el-table-column label="点币价格" align="center">
								<template slot-scope="scope">
									<span v-if="scope.row.bi_price">{{scope.row.bi_price}}元</span>
								</template>
							</el-table-column>
							<el-table-column label="点币" align="center">
								<template slot-scope="scope">
									<span v-if="scope.row.dian_bi">{{scope.row.dian_bi}}</span>
								</template>
							</el-table-column>
							<el-table-column label="卖价" align="center">
								<template slot-scope="scope">
									<span v-if="scope.row.sale_price">{{scope.row.sale_price}}元</span>
								</template>
							</el-table-column>
							<el-table-column label="库存" align="center">
								<template slot-scope="scope">
									<span class="item__detail--value">{{scope.row.stocks}}</span>
								</template>
							</el-table-column>
							<el-table-column label="供应商" align="center" width="150">
								<template slot-scope="scope" v-if="scope.row.supplier">
									<span class="item__detail--value">{{scope.row.supplier.supplier_name}}</span>
									<br/>
									<span class="item__detail--value">{{scope.row.supplier.link_man}}</span>
									<br/>
									<span class="item__detail--value">{{scope.row.supplier.mobile}}</span>
								</template>
							</el-table-column>
						</el-table>
					</div>
				</div>

			</div>
		</div>
	</div>
	</div>
</template>

<script>
	export default {
		props: ["id"],
		data() {
			return {
				/*data: {
					member: {},
					address: {},
					company: {},
					warehouse: {},
					order_state: {},
					invoice: {}
				},*/
				data: null,
				loading: true
			}
		},
		created() {
			this.fetchOrderDetail();
		},
		methods: {
			close() {
				this.$parent.showModel = false;
			},
			fetchOrderDetail() {
				this.loading = true;
				var url = `${this.url}/order/order_get_order_detail_man.action`;
				var params = {
					order_id: this.id
				};
				this.$http.get(url, {
					params
				}).then((res) => {
					this.loading = false;
					this.data = res.data.result;
				});
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>